package cqut.demo.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cqut.demo.dao.entity.User;
import cqut.demo.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wuyoushan
 * @date 2017/1/21.
 */
@RestController
@RequestMapping(value = "userRest")
public class UserRestController {
    @Autowired
    private UserMapper userMapper;

    //获取用户信息
    @RequestMapping(value = "/getUser.do",method = RequestMethod.GET)
    public User getUser(@RequestParam Integer id){
        User user=userMapper.findUserByID(id);
        return user;
    }

    //获取用户列表
    @RequestMapping(value="/restList.do",method= RequestMethod.GET)
    public List<User> list(){
        PageHelper.startPage(0,3);
        List<User> list=userMapper.findAllUser();
        PageInfo<User> pageInfo=new PageInfo<>(list);
        return list;
    }
}
